#include "mepwindow.h"
#include "ui_mepwindow.h"

#include <QDebug>

#include "expr.h"
#include <iostream>
#include <string>
#include <map>

MepWindow::MepWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MepWindow)
{
    ui->setupUi(this);
    ExprInit();
}

MepWindow::~MepWindow()
{
    delete ui;
}

void MepWindow::on_evalBtn_clicked()
{
    map<string,double> vars;
    double result = 0.0;
    string str = ui->expr->text().toStdString();

    vars["a"] = 0;
    vars["b"] = 1;

    try {
        result = ExprEvaluate(str, vars);
    } catch(ExprError &e) {
        qDebug() << e.info.data();
    }
    qDebug() << result;
    ui->result->setText(QString("Result: %1").arg(result));
}
